/*
Copyright (c) 2013 Javier Soto.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/

#import <UIKit/UIKit.h>

/**
 * 设置角标徽章所在位置；
 * 上左；
 * 上右；
 * 上中；
 * 中左；
 * 中右；
 * 下左；
 * 下右；
 * 下中；
 * 父视图正中心
 */
typedef NS_ENUM(NSUInteger, JSBadgeViewAlignment)
{
    JSBadgeViewAlignmentTopLeft = 1,
    JSBadgeViewAlignmentTopRight,
    JSBadgeViewAlignmentTopCenter,
    JSBadgeViewAlignmentCenterLeft,
    JSBadgeViewAlignmentCenterRight,
    JSBadgeViewAlignmentBottomLeft,
    JSBadgeViewAlignmentBottomRight,
    JSBadgeViewAlignmentBottomCenter,
    JSBadgeViewAlignmentCenter
};

@interface JSBadgeView : UIView

/**
 * 设置角标徽章显示的文字，一般是数字
 */
@property (nonatomic, copy) NSString *badgeText;

#pragma mark - Customization
/**
 * 显示角标徽章在父视图上的位置
 */
@property (nonatomic, assign) JSBadgeViewAlignment badgeAlignment UI_APPEARANCE_SELECTOR;
/**
 * 显示角标徽章文字颜色
 */
@property (nonatomic, strong) UIColor *badgeTextColor UI_APPEARANCE_SELECTOR;
/**
 * 显示角标徽章文字阴影偏移量
 */
@property (nonatomic, assign) CGSize badgeTextShadowOffset UI_APPEARANCE_SELECTOR;
/**
 * 显示角标徽章文字阴影颜色
 */
@property (nonatomic, strong) UIColor *badgeTextShadowColor UI_APPEARANCE_SELECTOR;
/**
 * 显示角标徽章文字字号格式
 */
@property (nonatomic, strong) UIFont *badgeTextFont UI_APPEARANCE_SELECTOR;
/**
 * 显示角标徽章背景颜色
 */
@property (nonatomic, strong) UIColor *badgeBackgroundColor UI_APPEARANCE_SELECTOR;

/**
 * @discussion Color of the overlay circle at the top. Default is semi-transparent white.
 * 讨论 顶部圆形覆盖视图颜色，默认是半透明的白色，是反光面颜色，一般设为[UIColor clearColor] 或者
 */
@property (nonatomic, strong) UIColor *badgeOverlayColor UI_APPEARANCE_SELECTOR;

/**
 * Color of the badge shadow. Default is semi-transparent black.
 * 角标徽章的阴影颜色，默认是半透明的黑色
 */
@property (nonatomic, strong) UIColor *badgeShadowColor UI_APPEARANCE_SELECTOR;

/**
 * Offset of the badge shadow. Default is 3.0 points down.
 * 角标徽章的阴影偏移，默认是向下偏移3.0个点
 */
@property (nonatomic, assign) CGSize badgeShadowSize UI_APPEARANCE_SELECTOR;

/**
 * Width of the circle around the badge. Default is 2.0 points.
 * 角标徽章边缘的宽度，默认是2.0个点
 */
@property (nonatomic, assign) CGFloat badgeStrokeWidth UI_APPEARANCE_SELECTOR;

/**
 * Color of the circle around the badge. Default is white.
 * 角标徽章边缘的颜色，默认是白色
 */
@property (nonatomic, strong) UIColor *badgeStrokeColor UI_APPEARANCE_SELECTOR;

/**
 * Allows to shift the badge by x and y points.
 * 使用这一属性允许改变角标徽章的起点 x 、y
 */
@property (nonatomic, assign) CGPoint badgePositionAdjustment UI_APPEARANCE_SELECTOR;

/**
 * You can use this to position the view if you're drawing it using drawRect instead of `-addSubview:`
 * (optional) If not provided, the superview frame is used.
 * 如果你使用使用绘制矩形方法绘制它,而不是“addsubview:”方法，你可以使用这一属性安置该视图
 *(可选)如果没有提供,使用父视图框架。
 */
@property (nonatomic, assign) CGRect frameToPositionInRelationWith UI_APPEARANCE_SELECTOR;

/**
 * The minimum width of a badge circle. We need this to avoid elipse shapes when using small fonts.
 * 设置圆形角标徽章的最小宽度，当实用小字体时我们需要这一方法去避免形成椭圆形
 */
@property (nonatomic, assign) CGFloat badgeMinWidth UI_APPEARANCE_SELECTOR;

/**
 * Optionally init using this method to have the badge automatically added to another view.
 * 使用这种 有选择性的init方法 去自动给其他视图添加角标徽章
 */
- (id)initWithParentView:(UIView *)parentView alignment:(JSBadgeViewAlignment)alignment;

@end
